﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FelMaster.Dev;

namespace FelMaster.ClassButton
{
    public partial class Settings : Form
    {
        private static Settings instance = new Settings();
        private static FelMaster FM = null;

        public static void Display(FelMaster FM)
        {
            Settings.FM = FM;
            if (instance == null || instance.IsDisposed)
                instance = new Settings();
            if (!instance.Visible)
            {
                instance.Show();
            }
        }

        private Settings()
        {
            InitializeComponent();

            this.single_cooldowns.Checked = SettingsFile.Instance.Single_HandleBurstCooldowns;
            this.single_movement.Checked = SettingsFile.Instance.Single_HandleMovement;

            this.party_cooldowns.Checked = SettingsFile.Instance.Party_HandleBurstCooldowns;
            this.party_movement.Checked = SettingsFile.Instance.Party_HandleMovement;

            this.bg_cooldowns.Checked = SettingsFile.Instance.Battleground_HandleBurstCooldowns;
            this.bg_movement.Checked = SettingsFile.Instance.Battleground_HandleMovement;

            this.FormClosing += new FormClosingEventHandler(saveSettings);
        }

        void saveSettings(object sender, EventArgs e)
        {
            SettingsFile.Instance.Single_HandleBurstCooldowns = this.single_cooldowns.Checked;
            SettingsFile.Instance.Single_HandleMovement = this.single_movement.Checked;

            SettingsFile.Instance.Party_HandleBurstCooldowns = this.party_cooldowns.Checked;
            SettingsFile.Instance.Party_HandleMovement = this.party_movement.Checked;

            SettingsFile.Instance.Battleground_HandleBurstCooldowns = this.bg_cooldowns.Checked;
            SettingsFile.Instance.Battleground_HandleMovement = this.bg_movement.Checked;

            SettingsFile.Instance.Save();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SelectClass.Display(FM);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SpellLockWatcher.Display();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            AreaDebugger.Display();
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=PEB7V5MR5GSN6&lc=US&item_name=Cowdude%27s%20dev%2e%20support&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted");
        }

        private void button4_Click(object sender, EventArgs e)
        {
            TargetInfo.Display();
        }
    }
}
